﻿using System;

namespace Trentacular.Office.Server.Search.FacetedSearch.Providers
{
    /// <summary>
    /// The common interface for a managed property facet builder that is used by the
    /// <see cref="ManagedPropertyFacetProvider" /> class.
    /// </summary>
    public interface IManagedPropertyFacetBuilder
    {
        /// <summary>
        /// Gets or sets the faceted search context.
        /// </summary>
        /// <value>The faceted search context.</value>
        FacetedSearchContext FacetedSearchContext { get; set; }

        /// <summary>
        /// Gets or sets the facet provider configuration.
        /// </summary>
        /// <value>The facet provider configuration.</value>
        FacetProviderConfiguration Configuration { get; set; }

        /// <summary>
        /// Gets or sets the name of the managed property.
        /// </summary>
        /// <value>The name of the managed property.</value>
        string ManagedPropertyName { get; set; }

        /// <summary>
        /// Indicating whether the <see cref="ManagedPropertyFacetProvider" /> should
        /// sort the resulting facets by their keys.
        /// </summary>
        /// <value><c>true</c> if the <see cref="ManagedPropertyFacetProvider" />
        /// should sort the resulting facets by their keys; otherwise, <c>false</c>.
        /// </value>
        bool SortByKey { get; }

        /// <summary>
        /// Gets the facet keys for a single search result's managed property value.
        /// </summary>
        /// <param name="value">The facet keys for a single search result's managed
        /// property value.</param>
        /// <returns>An array of keys.</returns>
        string[] GetKeys(object value);

        /// <summary>
        /// Creates a facet for a given facet key and managed property value.
        /// </summary>
        /// <param name="key">The facet's key.</param>
        /// <param name="value">The managed property value.</param>
        /// <returns>The generated facet.</returns>
        Facet CreateFacet(string key, object value);
    }
}
